Skip to content

Fix Work auto-create lane launch and naming#303

Merged
arul28 merged 7 commits into
mainfrom
ade/chat-20260514-125013-4a9584d5
May 14, 2026
Merged

Fix Work auto-create lane launch and naming#303
arul28 merged 7 commits into
mainfrom
ade/chat-20260514-125013-4a9584d5

Conversation

@arul28
Copy link
Copy Markdown
Owner

@arul28 arul28 commented May 14, 2026

Summary

  • route foreground auto-created chats back into Work instead of the Lanes tab
  • surface background-created chats optimistically without stealing focus, with a dismissible success notice
  • run lane naming through provider-aware session intelligence with model retries before deterministic fallback

Verification

  • npm --prefix apps/desktop run test -- agentChatService.suggestLaneName.test.ts
  • npm --prefix apps/desktop run test -- AgentChatPane.submit.test.tsx
  • npm --prefix apps/desktop run test -- useWorkSessions.test.ts
  • npm --prefix apps/desktop run test -- WorkStartSurface.test.tsx
  • targeted ESLint on changed files: 0 errors
  • git diff --check

Note: repo-wide typecheck was blocked locally by missing installed node_modules entries for builder-util-runtime and @types/mdast, both already present in package-lock.json.

Summary by CodeRabbit

  • New Features

    • Added auto-create lane functionality for foreground and background chat sessions with intelligent lane naming.
    • Introduced dismissible notifications for background-created chat sessions.
  • Bug Fixes

    • Fixed scroll-into-view behavior in lane selection.
  • Improvements

    • Enhanced session creation callbacks to pass context about how sessions were created (foreground vs. background activation).
    • Made PTY probe timeout configurable via environment variable instead of hardcoded value.

Review Change Stack

Greptile Summary

This PR fixes two related bugs in the Work auto-create lane flow: foreground-launched chats now navigate to /work instead of the Lanes tab, and background-launched chats are surfaced optimistically via upsertOptimisticChatSession without stealing focus, with a new dismissible notice. It also replaces the single-model runOpenCodeTextPrompt call for lane naming with a multi-candidate retry loop through runSessionIntelligencePrompt, adds a unique timestamp suffix to prompt-derived fallback names, and hardens error cleanup so auto-created lanes and sessions are rolled back when any step fails.

  • AgentChatPane.tsx moves notifySessionCreated to after a successful send, always passes activate: false for draft-launch paths (foreground navigation is delegated to openLaunchedDraftChat), and adds a full catch-path that deletes the orphaned session/lane on failure.
  • agentChatService.ts introduces GENERIC_PROMPT_LANE_NAME constant, uniquePromptFallbackLaneName for collision-safe slug+timestamp names, and a sequential retry loop over candidate models before deterministic fallback.
  • packagedRuntimeSmoke.ts makes the PTY probe timeout configurable via ADE_PACKAGED_PTY_PROBE_TIMEOUT_MS and switches the Windows probe from PowerShell to the lighter-weight cmd.exe.

Confidence Score: 5/5

Safe to merge — all three behavioral fixes (foreground routing, background optimistic surface, lane naming retries) are well-scoped, the error-path lane/session rollback addresses the orphaned-lane concern from the previous review, and test coverage spans all new code paths.

The changes are tightly contained: routing fix in openLaunchedDraftChat, activation gating in TerminalsPage, retry loop in agentChatService. The error-cleanup path is now covered by dedicated tests. The only finding is a documentation inaccuracy about the activate flag value for foreground launches — the runtime behavior is correct.

docs/features/chat/composer-and-ui.md contains an inaccurate description of the foreground activate flag value that a suggestion comment addresses.

Important Files Changed

Filename Overview
apps/desktop/src/renderer/components/chat/AgentChatPane.tsx Exports AgentChatSessionCreatedOptions; fixes foreground auto-create to navigate to /work instead of /lanes; moves notifySessionCreated to after successful send (always with activate:false); adds full error-path cleanup for auto-created sessions and lanes; adds dismiss button to background launch notice
apps/desktop/src/main/services/chat/agentChatService.ts Migrates suggestLaneNameFromPrompt from single-model runOpenCodeTextPrompt to a multi-candidate retry loop via runSessionIntelligencePrompt; adds GENERIC_PROMPT_LANE_NAME constant; refactors fallback to uniquePromptFallbackLaneName for collision-free slug+timestamp names; moves titleGenerationEnabled guard before detectAuth() for an early-exit win
apps/desktop/src/renderer/components/terminals/TerminalsPage.tsx handleOpenChatSession now accepts optional AgentChatSessionCreatedOptions; selectLane/focusSession/openSessionTab are skipped when activate===false, supporting background auto-create without focus theft
apps/desktop/src/renderer/components/terminals/TerminalsPage.test.tsx New test file covering background vs foreground session activation in TerminalsPage; verifies background sessions upsert without stealing focus and foreground sessions fully activate
apps/desktop/src/main/packagedRuntimeSmoke.ts PTY probe timeout made configurable via ADE_PACKAGED_PTY_PROBE_TIMEOUT_MS env var; Windows probe switched from PowerShell to cmd.exe for lighter-weight startup; timeout error message now includes shell binary name
apps/desktop/src/renderer/components/terminals/LaneCombobox.tsx Defensive guard added around scrollIntoView call to prevent test-environment errors where the method may not exist on listRef children
docs/features/chat/composer-and-ui.md Documents Work auto-create launch behavior; contains an inaccuracy — states foreground launches pass activate:true but code always passes activate:false for both foreground and background

Sequence Diagram

sequenceDiagram
    participant User
    participant AgentChatPane
    participant agentChatService
    participant lanes as window.ade.lanes
    participant chat as window.ade.agentChat
    participant TerminalsPage

    User->>AgentChatPane: Send / Launch in background

    AgentChatPane->>agentChatService: "suggestLaneName({prompt, modelId, fallbackName})"
    Note over agentChatService: Try requestedModel → configuredModel → defaults<br/>Each failure retries next candidate<br/>Fallback: prompt-slug + timestamp suffix
    agentChatService-->>AgentChatPane: laneName

    AgentChatPane->>lanes: "create({name: laneName, parentLaneId})"
    lanes-->>AgentChatPane: createdLane

    AgentChatPane->>chat: "createSession({laneId: createdLane.id})"
    chat-->>AgentChatPane: createdSession

    AgentChatPane->>chat: "send({sessionId, text, ...})"

    alt send succeeds
        chat-->>AgentChatPane: ok
        AgentChatPane->>TerminalsPage: "onSessionCreated(session, {activate: false, source: draft-launch})"
        TerminalsPage->>TerminalsPage: upsertOptimisticChatSession (no focus steal)

        alt foreground mode
            AgentChatPane->>AgentChatPane: "openLaunchedDraftChat → navigate(/work?laneId&sessionId)"
        else background mode
            AgentChatPane->>AgentChatPane: setBackgroundLaunchNotice (dismissible)
        end
    else send fails (catch)
        AgentChatPane->>chat: "delete({sessionId})"
        AgentChatPane->>lanes: "delete({laneId, force:true})"
        AgentChatPane->>AgentChatPane: restoreDraftLaunchSnapshot + setError
    end
Loading

Comments Outside Diff (1)

  1. apps/desktop/src/renderer/components/chat/AgentChatPane.tsx, line 4280-4310 (link)

    P2 Foreground auto-create activates the new session twice in embedded layout

    createSessionForLane is called with notify: true, notifyOptions: { activate: true }, which immediately fires handleOpenChatSession in TerminalsPage (calling work.selectLane, work.focusSession, work.openSessionTab for the new lane). Then openLaunchedDraftChat(launch) is also called for mode === "foreground", setting overlapping work view state and navigating again. The double-activation is harmless in the happy path but could cause brief state flicker. Consider passing notify: false for foreground mode where openLaunchedDraftChat already handles navigation and state.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: apps/desktop/src/renderer/components/chat/AgentChatPane.tsx
    Line: 4280-4310
    
    Comment:
    **Foreground auto-create activates the new session twice in embedded layout**
    
    `createSessionForLane` is called with `notify: true, notifyOptions: { activate: true }`, which immediately fires `handleOpenChatSession` in `TerminalsPage` (calling `work.selectLane`, `work.focusSession`, `work.openSessionTab` for the new lane). Then `openLaunchedDraftChat(launch)` is also called for `mode === "foreground"`, setting overlapping work view state and navigating again. The double-activation is harmless in the happy path but could cause brief state flicker. Consider passing `notify: false` for foreground mode where `openLaunchedDraftChat` already handles navigation and state.
    
    How can I resolve this? If you propose a fix, please make it concise.

    Fix in Claude Code

Fix All in Claude Code

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
docs/features/chat/composer-and-ui.md:182-187
The documentation says foreground launches call `onSessionCreated` with `{ activate: true }`, but `AgentChatPane.tsx` always passes `{ activate: false, source: "draft-launch" }` for both foreground and background auto-create flows (line 4442). Foreground navigation is handled by `openLaunchedDraftChat` directly — it sets work view state and calls `navigate("/work?...")` — rather than relying on `TerminalsPage.handleOpenChatSession` activation. The `activate: true` path in `TerminalsPage` is exercised by non-draft-launch callers (regular new sessions), not by the draft-launch path. The `AgentChatPane.submit.test.tsx` asserts `{ activate: false }` for the foreground test case, confirming the doc is incorrect.

```suggestion
  The request includes a temporary `chat-YYYYMMDD-HHMMSS` fallback so
  prompt-derived fallback names remain unique when model naming is
  unavailable. Both foreground and background launches call `onSessionCreated`
  with `{ activate: false, source: "draft-launch" }` — foreground navigation
  is driven by `openLaunchedDraftChat` which sets work view state and routes
  to `/work?laneId=...`; background launches keep the current Work focus and
  show a dismissible notice with an Open action.
```

Reviews (6): Last reviewed commit: "merge main into lane" | Re-trigger Greptile

@vercel
Copy link
Copy Markdown

vercel Bot commented May 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
ade Ignored Ignored Preview May 14, 2026 8:57pm

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 14, 2026

📝 Walkthrough

Walkthrough

This PR refactors chat lane-name suggestion from OpenCode runtime to AI integration, introduces optional session-creation callback metadata for foreground/background launch distinction, implements draft background launch UX with dismiss affordance, adds auto-create testing infrastructure, and includes PTY probe timeout configurability and minor safety fixes.

Changes

Session creation callback contract and wiring

Layer / File(s) Summary
Session callback type and AgentChatPane integration
apps/desktop/src/renderer/components/chat/AgentChatPane.tsx
Introduces exported AgentChatSessionCreatedOptions type with activate and source fields; updates onSessionCreated prop to optionally receive options; implements notifySessionCreated to conditionally invoke callback with or without options based on caller intent.
Work-layout component callback wiring
apps/desktop/src/renderer/components/terminals/TerminalsPage.tsx, WorkViewArea.tsx, WorkStartSurface.tsx
Propagates AgentChatSessionCreatedOptions type through TerminalsPage, WorkViewArea, and WorkStartSurface; updates onOpenChatSession signatures to accept optional options; TerminalsPage conditionally skips lane activation (selectLane, focusSession, openSessionTab) when activate === false.

Lane name suggestion refactoring from OpenCode to AI integration

Layer / File(s) Summary
Fallback lane-name helpers with collision resistance
apps/desktop/src/main/services/chat/agentChatService.ts
Introduces GENERIC_PROMPT_LANE_NAME constant; refactors fallbackLaneNameFromPrompt to use it; adds uniquePromptFallbackLaneName to derive collision-resistant fallback by combining trimmed prompt prefix with sanitized explicit-fallback suffix.
Lane suggestion with model-candidate iteration
apps/desktop/src/main/services/chat/agentChatService.ts
Reworks suggestLaneNameFromPrompt to resolve chat config, early-exit if title generation disabled, detect auth, filter non-deprecated available models, construct ordered de-duplicated candidate list, and iteratively call runSessionIntelligencePrompt per candidate until normalized name obtained or fallback returned on all candidates exhausted.
Test mock infrastructure for AI integration
apps/desktop/src/main/services/chat/agentChatService.suggestLaneName.test.ts
Updates createMockProjectConfigService to accept titleModelId and wire through sessionIntelligence config; updates createService helper to accept titleModelId; adds aiIntegrationService.summarizeTerminal as mockable target; returns aiIntegrationService from createService for test expectations.
Test cases validating AI integration and fallback behavior
apps/desktop/src/main/services/chat/agentChatService.suggestLaneName.test.ts
Updates test cases from runOpenCodeTextPrompt mocking to summarizeTerminal mocking; validates fallback on AI error, title-generation-disabled behavior, success-path naming with AI output, model-retry when first model fails, and edge cases (truncation to 60 chars, hyphen trimming, empty text after sanitization).

Draft background launch implementation with new callback options

Layer / File(s) Summary
Draft launch UI and routing updates
apps/desktop/src/renderer/components/chat/AgentChatPane.tsx
Updates openLaunchedDraftChat to set explicit work view state (activeItemId, selectedItemId, draftKind, viewMode); branches routing on embeddedWorkLayout to navigate /work when embedded or /lanes otherwise; adds dismiss button (X icon) to background launch notice to clear backgroundLaunchNotice.
Auto-create lane naming with inline fallback
apps/desktop/src/renderer/components/chat/AgentChatPane.tsx
Updates auto-created lane name suggestions and parallel launch naming to pass fallbackName: createTemporaryAutoLaneName() inline to suggestLaneName; launches draft chat with notify: true and notifyOptions (activate: false, source: "draft-launch").

Comprehensive auto-create draft testing

Layer / File(s) Summary
Test mock infrastructure for auto-create
apps/desktop/src/renderer/components/chat/AgentChatPane.submit.test.tsx
Parameterizes agentChat.create mock to accept argument object and derive session fields (lane, provider, model, modelId, reasoning effort); adds mocked lanes.createLane implementation; exposes createLane from installAdeMocks return value; adds renderAutoCreateDraftPane helper to render AgentChatPane in /work route context with draft mode and callback.
AgentChatPane auto-create draft test cases
apps/desktop/src/renderer/components/chat/AgentChatPane.submit.test.tsx
Adds three auto-create scenarios: (1) foreground auto-create creates lane, sends first message, routes to created chat; (2) background auto-create shows dismissible notice, keeps /work until "Open" clicked, then routes to created session; (3) background launch disables send actions while keeping draft textbox editable; updates parallel-lane test to include fallbackName expectation in suggestLaneName call.
TerminalsPage session activation behavior tests
apps/desktop/src/renderer/components/terminals/TerminalsPage.test.tsx
Adds Vitest suite with jsdom environment, mocked store/hooks/child components, and test doubles; verifies background-created sessions skip lane activation (selectLane, focusSession, openSessionTab) while foreground-created sessions invoke full activation pipeline; asserts upsertOptimisticChatSession and refresh calls in both cases.

PTY smoke and LaneCombobox safety fixes

Layer / File(s) Summary
Configurable PTY probe timeout and shell command
apps/desktop/src/main/packagedRuntimeSmoke.ts
Introduces positiveIntegerEnv helper to parse and validate positive integers from environment; defines PTY_PROBE_TIMEOUT_MS from ADE_PACKAGED_PTY_PROBE_TIMEOUT_MS env (default 15000 ms); updates Windows PTY shell from PowerShell to cmd.exe /d /s /c echo ADE_PTY_OK; includes configured timeout and shell executable in timeout error message.
LaneCombobox scrollIntoView safety check
apps/desktop/src/renderer/components/terminals/LaneCombobox.tsx
Guards scrollIntoView invocation by checking typeof el?.scrollIntoView === "function" before calling to avoid runtime error if property is not callable.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes


Suggested labels

desktop

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and clearly summarizes the main change: fixing auto-create lane launch behavior and improving lane naming logic, which are the primary objectives across all file modifications.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ade/chat-20260514-125013-4a9584d5

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@capy-ai
Copy link
Copy Markdown

capy-ai Bot commented May 14, 2026

Capy auto-review is paused for this organization because the monthly auto-review limit has been reached. Increase the limit or turn it off in billing settings to resume automatic reviews.

@arul28 arul28 changed the title Chat 20260514 125013 Fix Work auto-create lane launch and naming May 14, 2026
Comment thread apps/desktop/src/main/services/chat/agentChatService.ts Outdated
Comment thread apps/desktop/src/main/services/chat/agentChatService.ts
@arul28
Copy link
Copy Markdown
Owner Author

arul28 commented May 14, 2026

@copilot review but do not make fixes

Copy link
Copy Markdown
Contributor

Copilot AI commented May 14, 2026

@copilot review but do not make fixes

Review-only pass completed (no fixes made). On bd730e9/4661ce0:

  • Issue 1 (hardcoded "parallel-task") is addressed via GENERIC_PROMPT_LANE_NAME.
  • Issue 2 (fallback uniqueness) is addressed by restoring fallbackName from createTemporaryAutoLaneName() and combining it through uniquePromptFallbackLaneName(...).
  • Issue 3 still appears open: foreground auto-create still does both notify: true with activate: true and openLaunchedDraftChat(...), so activation/navigation can happen twice in embedded Work layout.

Validation note: local targeted test run could not execute because vitest is not installed in this environment (sh: 1: vitest: not found).

Copilot finished work on behalf of arul28 May 14, 2026 19:15
@arul28
Copy link
Copy Markdown
Owner Author

arul28 commented May 14, 2026

@copilot review but do not make fixes

@arul28
Copy link
Copy Markdown
Owner Author

arul28 commented May 14, 2026

@copilot review but do not make fixes

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (3)
apps/desktop/src/renderer/components/terminals/TerminalsPage.test.tsx (1)

163-164: ⚡ Quick win

Reuse AgentChatSessionCreatedOptions in the WorkViewArea mock prop typing.

The inline { activate?: boolean; source?: ... } type can drift from the real callback contract and reduce test reliability.

Proposed change
-import type { AgentChatSession, LaneSummary } from "../../../shared/types";
+import type { AgentChatSession, LaneSummary } from "../../../shared/types";
+import type { AgentChatSessionCreatedOptions } from "../chat/AgentChatPane";

 vi.mock("./WorkViewArea", () => ({
   WorkViewArea: (props: {
-    onOpenChatSession: (session: AgentChatSession, options?: { activate?: boolean; source?: "chat" | "draft-launch" | "handoff" }) => void | Promise<void>;
+    onOpenChatSession: (
+      session: AgentChatSession,
+      options?: AgentChatSessionCreatedOptions,
+    ) => void | Promise<void>;
   }) => (

As per coding guidelines, "Keep IPC contracts, preload types, shared types, and renderer usage in sync whenever an interface changes in TypeScript".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/desktop/src/renderer/components/terminals/TerminalsPage.test.tsx` around
lines 163 - 164, The test mock for the WorkViewArea prop 'onOpenChatSession'
uses an inline type for the options object which can drift; replace the inline
type with the shared type AgentChatSessionCreatedOptions so the test signature
stays in sync with production. Locate the mock prop typing for onOpenChatSession
in TerminalsPage.test.tsx and import and use AgentChatSessionCreatedOptions
(alongside AgentChatSession if needed) instead of the inline { activate?:
boolean; source?: "chat" | "draft-launch" | "handoff" } definition, updating any
related imports or type annotations to match.
apps/desktop/src/renderer/components/chat/AgentChatPane.submit.test.tsx (1)

420-422: ⚡ Quick win

Use the concrete session-created options type in this helper signature.

options?: any drops compile-time coverage for the callback contract and can let interface drift slip through tests.

Proposed change
-import { AgentChatPane, isMatchingOptimisticUserMessage } from "./AgentChatPane";
+import {
+  AgentChatPane,
+  isMatchingOptimisticUserMessage,
+  type AgentChatSessionCreatedOptions,
+} from "./AgentChatPane";

 function renderAutoCreateDraftPane(args?: {
-  onSessionCreated?: (session: AgentChatSession, options?: any) => void | Promise<void>;
+  onSessionCreated?: (
+    session: AgentChatSession,
+    options?: AgentChatSessionCreatedOptions,
+  ) => void | Promise<void>;
 }) {

As per coding guidelines, "Keep IPC contracts, preload types, shared types, and renderer usage in sync whenever an interface changes in TypeScript".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/desktop/src/renderer/components/chat/AgentChatPane.submit.test.tsx`
around lines 420 - 422, The helper renderAutoCreateDraftPane's onSessionCreated
callback currently uses a loose options?: any parameter; replace that any with
the concrete session-created options type used by the AgentChatSession API
(e.g., the exported type used wherever sessions are created, such as
AgentChatSessionCreatedOptions or SessionCreatedOptions) so the test helper's
signature matches the real IPC/renderer contract; import that specific type and
update the signature in renderAutoCreateDraftPane (and any test callers) to
options?: ThatConcreteType to restore compile-time coverage.
apps/desktop/src/main/services/chat/agentChatService.ts (1)

6581-6594: 💤 Low value

Extract hardcoded fallback model IDs to module-level constant; note existing redundancy.

The inline fallback model list is repeated five times throughout this file (lines 5774–5778, 6024–6027, 6219–6223, 6582–6589, and 8040–8044). Extracting these four IDs to a module-level constant would improve maintainability. However, note that DEFAULT_AUTO_TITLE_MODEL_ID is already defined at line 1581 as "anthropic/claude-haiku-4-5", which is hardcoded again as the first fallback entry—this is redundant. The refactor should eliminate this duplication and apply consistently across all five locations.

Regarding the claim about openai/gpt-5.2 deprecation: this model is not currently marked deprecated: true in modelRegistry.ts, so a June 2026 retirement date cannot be verified from the codebase.

♻️ Revised extraction
+// Ordered fallback candidates tried after the user/config/default title model.
+// Listed in preference order; entries are skipped if not present in the
+// available (non-deprecated) registry, so stale IDs degrade gracefully.
+const TITLE_MODEL_FALLBACK_CANDIDATES = [
+  "openai/gpt-5.4-mini",
+  "openai/gpt-5.2",
+  "openai/gpt-5.4",
+] as const;
@@
-      const candidateModelIds = [
-        requestedModelId,
-        config.titleModelId,
-        DEFAULT_AUTO_TITLE_MODEL_ID,
-        "anthropic/claude-haiku-4-5",
-        "openai/gpt-5.4-mini",
-        "openai/gpt-5.2",
-        "openai/gpt-5.4",
-        availableModels[0]?.id,
-      ].reduce<string[]>((acc, candidate) => {
+      const candidateModelIds = [
+        requestedModelId,
+        config.titleModelId,
+        DEFAULT_AUTO_TITLE_MODEL_ID,
+        ...TITLE_MODEL_FALLBACK_CANDIDATES,
+        availableModels[0]?.id,
+      ].reduce<string[]>((acc, candidate) => {

Note: Apply to all five occurrences for consistency.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/desktop/src/main/services/chat/agentChatService.ts` around lines 6581 -
6594, The inline fallback model list used when building candidateModelIds is
duplicated across the file; extract those hardcoded IDs into a single
module-level constant (e.g., FALLBACK_MODEL_IDS or FALLBACK_MODEL_CANDIDATES)
and reference that constant inside the candidateModelIds construction
(function/variable: candidateModelIds) instead of repeating the array—remove the
redundant literal "anthropic/claude-haiku-4-5" from the inline list because
DEFAULT_AUTO_TITLE_MODEL_ID already equals that value, and ensure all other
occurrences that currently inline the same list are updated to use the new
constant so the set of fallbacks is maintained consistently (keep the dynamic
availableModels[0]?.id inclusion and the filtering logic with availableIds.has).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/desktop/src/renderer/components/chat/AgentChatPane.tsx`:
- Around line 4290-4297: The code creates a session via createSessionForLane and
calls notifySessionCreated before performing the initial send, but if send
rejects the created session/lane is left behind; either move
notifySessionCreated until after send resolves, or if you must optimistically
notify, catch send failures and roll back the created session by
removing/deleting it and reversing the notification. Concretely: keep the
created variable from createSessionForLane, perform send in a try/catch, and on
catch call the existing cleanup API (e.g., deleteSessionForLane or
removeSession/rollbackSession using created.sessionId) and/or call the inverse
notification (e.g., notifySessionDeleted or revert notifySessionCreated) before
restoring the draft UI; apply the same change at the other occurrence around the
send (lines 4325-4328).
- Around line 4023-4028: notifySessionCreated currently calls onSessionCreated
directly so a synchronous throw escapes Promise.resolve’s catch; change the
invocation to run inside Promise.resolve().then(...) (e.g.
Promise.resolve().then(() => options === undefined ? onSessionCreated(session) :
onSessionCreated(session, options))).then(...) or a single Promise chain and
attach .catch(...) so both synchronous and async errors from onSessionCreated
are caught; update the notifySessionCreated function accordingly.

---

Nitpick comments:
In `@apps/desktop/src/main/services/chat/agentChatService.ts`:
- Around line 6581-6594: The inline fallback model list used when building
candidateModelIds is duplicated across the file; extract those hardcoded IDs
into a single module-level constant (e.g., FALLBACK_MODEL_IDS or
FALLBACK_MODEL_CANDIDATES) and reference that constant inside the
candidateModelIds construction (function/variable: candidateModelIds) instead of
repeating the array—remove the redundant literal "anthropic/claude-haiku-4-5"
from the inline list because DEFAULT_AUTO_TITLE_MODEL_ID already equals that
value, and ensure all other occurrences that currently inline the same list are
updated to use the new constant so the set of fallbacks is maintained
consistently (keep the dynamic availableModels[0]?.id inclusion and the
filtering logic with availableIds.has).

In `@apps/desktop/src/renderer/components/chat/AgentChatPane.submit.test.tsx`:
- Around line 420-422: The helper renderAutoCreateDraftPane's onSessionCreated
callback currently uses a loose options?: any parameter; replace that any with
the concrete session-created options type used by the AgentChatSession API
(e.g., the exported type used wherever sessions are created, such as
AgentChatSessionCreatedOptions or SessionCreatedOptions) so the test helper's
signature matches the real IPC/renderer contract; import that specific type and
update the signature in renderAutoCreateDraftPane (and any test callers) to
options?: ThatConcreteType to restore compile-time coverage.

In `@apps/desktop/src/renderer/components/terminals/TerminalsPage.test.tsx`:
- Around line 163-164: The test mock for the WorkViewArea prop
'onOpenChatSession' uses an inline type for the options object which can drift;
replace the inline type with the shared type AgentChatSessionCreatedOptions so
the test signature stays in sync with production. Locate the mock prop typing
for onOpenChatSession in TerminalsPage.test.tsx and import and use
AgentChatSessionCreatedOptions (alongside AgentChatSession if needed) instead of
the inline { activate?: boolean; source?: "chat" | "draft-launch" | "handoff" }
definition, updating any related imports or type annotations to match.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b4094a2b-b5bb-4054-bb84-487c35d99db6

📥 Commits

Reviewing files that changed from the base of the PR and between 9724fcc and fb42e08.

⛔ Files ignored due to path filters (3)
  • docs/features/chat/README.md is excluded by !docs/**
  • docs/features/chat/composer-and-ui.md is excluded by !docs/**
  • docs/features/terminals-and-sessions/README.md is excluded by !docs/**
📒 Files selected for processing (10)
  • apps/desktop/src/main/packagedRuntimeSmoke.ts
  • apps/desktop/src/main/services/chat/agentChatService.suggestLaneName.test.ts
  • apps/desktop/src/main/services/chat/agentChatService.ts
  • apps/desktop/src/renderer/components/chat/AgentChatPane.submit.test.tsx
  • apps/desktop/src/renderer/components/chat/AgentChatPane.tsx
  • apps/desktop/src/renderer/components/terminals/LaneCombobox.tsx
  • apps/desktop/src/renderer/components/terminals/TerminalsPage.test.tsx
  • apps/desktop/src/renderer/components/terminals/TerminalsPage.tsx
  • apps/desktop/src/renderer/components/terminals/WorkStartSurface.tsx
  • apps/desktop/src/renderer/components/terminals/WorkViewArea.tsx

Comment thread apps/desktop/src/renderer/components/chat/AgentChatPane.tsx Outdated
Comment thread apps/desktop/src/renderer/components/chat/AgentChatPane.tsx Outdated
@arul28
Copy link
Copy Markdown
Owner Author

arul28 commented May 14, 2026

@copilot review but do not make fixes

Comment thread apps/desktop/src/renderer/components/chat/AgentChatPane.tsx Outdated
@arul28
Copy link
Copy Markdown
Owner Author

arul28 commented May 14, 2026

@copilot review but do not make fixes

@arul28
Copy link
Copy Markdown
Owner Author

arul28 commented May 14, 2026

@copilot review but do not make fixes

@arul28 arul28 merged commit b5f81b0 into main May 14, 2026
28 of 29 checks passed
Copilot stopped work on behalf of arul28 due to an error May 14, 2026 21:16
@arul28 arul28 deleted the ade/chat-20260514-125013-4a9584d5 branch May 14, 2026 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants